
package springredis.com.lei.service.impl;

import java.io.Serializable;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import springredis.com.lei.entity.Article;
import springredis.com.lei.mapper.ArticleMapper;
import springredis.com.lei.service.BlogsService;

/**
 * @author wangyl-910
 * @description
 * @date 2018/2/26
 * @see
 */
@Service
public class BlogsServiceSpringCacheRedisImpl extends ServiceImpl<ArticleMapper, Article> implements BlogsService {

    private static final Logger LOGGER = LoggerFactory.getLogger(BlogsServiceSpringCacheRedisImpl.class);

    @Override
    @CacheEvict(cacheNames = "user", key = "#id")
    public boolean removeById(Serializable id) {
        // TODO Auto-generated method stub
        return super.removeById(id);
    }

    @Override
    @CacheEvict(cacheNames = "user", key = "#entity.testId")
    public boolean updateById(Article entity) {
        return super.updateById(entity);
    }

    @Override
    @Cacheable(cacheNames = "user", key = "#id")
    public Article getById(Serializable id) {
        LOGGER.debug("从数据库获取数据{0}", id);
        return super.getById(id);
    }
}
